﻿<Window x:Class="CodeSHARPer.View.Dialogs.GotoLineView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

        xmlns:behav="clr-namespace:CodeSHARPer.Behaviour"
        xmlns:conv="clr-namespace:CodeSHARPer.Converter.MessageType"

        Title="Go To Line"
        ResizeMode="NoResize"
        SizeToContent="WidthAndHeight"
        WindowStartupLocation="CenterOwner"
        ShowInTaskbar="false"
        MinWidth="300">

    <Window.Resources>
        <conv:CountToVisibilityHiddenConverter x:Key="CountToVisibilityHidden" />
        <conv:MsgTypeToResourceConverter x:Key="MsgTypeToResource" />
    </Window.Resources>

    <Grid Margin="9,3">
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <Grid Margin="9,3" Grid.Row="0">
            <Grid.RowDefinitions>
                <RowDefinition Height="*" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>

            <StackPanel Grid.Row="0" Margin="0,9">
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
                    <Label Content="Line" Margin="0"/>
                    <Label Content=" " Margin="0"/>
                    <Label Content="{Binding MinMaxRange}" Margin="0" />
                    <Label Content=":" Margin="0"/>

                </StackPanel>
                <TextBox Text="{Binding LineNumberInput, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
                         MaxLines="1" MaxLength="10"
                         Name="PART_TxtLineNumber" />
            </StackPanel>

            <StackPanel Grid.Row="1">
                <StackPanel Visibility="{Binding ListMessages.Count, Converter={StaticResource CountToVisibilityHidden}}" Margin="0,15">
                    <TextBlock Text="{Binding ProblemCaption}" TextWrapping="Wrap" Margin="3" />

                    <ListBox ItemsSource="{Binding ListMessages}" MaxHeight="65"
                             BorderBrush="Transparent"
                             Background="Transparent"
                             Grid.Row="1"
                             VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal" ToolTip="{Binding MessageType}" Background="Transparent">
                                    <Image Source="{Binding CategoryOfMsg, Converter={StaticResource MsgTypeToResource}}"
                                           Width="16" Margin="3" HorizontalAlignment="Left" VerticalAlignment="Center" />
                                    <TextBlock Text="{Binding Message}" Margin="3" HorizontalAlignment="Left" VerticalAlignment="Center" />
                                </StackPanel>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                </StackPanel>
            </StackPanel>
        </Grid>

        <Grid Grid.Row="1" VerticalAlignment="Bottom" HorizontalAlignment="Right" Grid.IsSharedSizeScope="True">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" SharedSizeGroup="StandardButtons" />
                <ColumnDefinition Width="Auto" SharedSizeGroup="StandardButtons"/>
            </Grid.ColumnDefinitions>
            <Button Content="_Cancel"
                    Command="{Binding CancelCommand}"
                    IsCancel="True"
                    Grid.Column="0" Padding="3" Margin="6" MinHeight="24" MinWidth="80"/>

            <Button Content="_OK"
                    Command="{Binding OKCommand}"
                    IsDefault="True"
                    Grid.Column="1" Padding="3" Margin="6" MinHeight="24" MinWidth="80"/>
        </Grid>
    </Grid>
</Window>
